// pages/my/my.js
var httpTool = require('../../utils/network.js');
var util = require('../../utils/util.js')
const app = getApp()
Page({
  data:{
    openCityList: [],
    namingId:'',
  },
  //获得开通城市列表
  getOpenCityList: function () {
    var that = this;
    var url = app.data.httpUrl + 'v1/region/getOpenCityListByNamingId'
    var param = {
      namingId: this.data.namingId,
    }
    httpTool.sendRequest(url, param, '', function (res) {
      that.setData({
        openCityList: res.list
      })
      console.log("openCityList:");
      console.log(res.list)
    }, function (error) {
      console.log("加载冠名公司开通城市列表异常:", error);
    })
  },
  //跳转到报名页面
  toSignup: function (event) {

    var memberId = "";
    var memberPhone = "";
    if (app.userData.userId) {
      var namingId = this.data.namingId;
      var cityInfo = event.currentTarget.dataset.model;
      var vacationId = app.globalData.vacationId;//圆满假期ID
      util.navigateTo(
       '/pages/signup/signup?namingId=' + namingId + '&regionId=' + cityInfo.id + '&regionName=' + cityInfo.keyName + '&vacationId=' + vacationId
	  	)
    } else {
      util.navigateTo('/pages/login/login');
    }
  },
  onLoad:function(options){
    // 生命周期函数--监听页面加载
    //获取冠名公司开通城市列表
    var namingId = options.namingId;
    this.setData({
      namingId: namingId,
    })
    this.getOpenCityList();
  },
  onReady:function(){
    // 生命周期函数--监听页面初次渲染完成
    
  },
  onShow:function(){
    // 生命周期函数--监听页面显示
    
  },
  onHide:function(){
    // 生命周期函数--监听页面隐藏
    
  },
  onUnload:function(){
    // 生命周期函数--监听页面卸载
    
  },
  onPullDownRefresh: function() {
    // 页面相关事件处理函数--监听用户下拉动作
    
  },
  onReachBottom: function() {
    // 页面上拉触底事件的处理函数
    
  },
  onShareAppMessage: function() {
    // 用户点击右上角分享
    return {
      title: 'title', // 分享标题
      desc: 'desc', // 分享描述
      path: 'path' // 分享路径
    }
  }
})
